package com.tourism.common;

import lombok.Data;


@Data
public class Result {
    private Integer code;//状态码
    private String msg;//往前段响应的内容（文本）
    private Object data;//往前段响应的数据


    public Result(Object data) {
        this.data = data;
    }


    public Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Result(Integer code,  Object data) {
        this.code = code;
        this.data = data;
    }
    public Result(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Result success(String msg){
        return  new Result(200,msg);
    }


    public static Result success(Integer code,Object data){
        return  new Result(code,data);
    }
    public static Result success(Object data){
        return  new Result(data);
    }
    public static Result success(String msg,Object data){
        return  new Result(200,msg,data);
    }


    public static Result fail(String msg){
        return  new Result(500,msg);
    }
    public static Result fail(String msg,Object data){
        return  new Result(500,msg,data);
    }
    public static <T> Result error(String msg) {
        return new Result(500, msg, null);
    }
}